import Vue from 'vue'
import VueApollo from 'vue-apollo'
import { ApolloClient } from 'apollo-client'
import { HttpLink } from 'apollo-link-http'
import { InMemoryCache } from 'apollo-cache-inmemory'
import fetch from 'unfetch'

// Install the vue plugin
Vue.use(VueApollo);

const httpLink = new HttpLink({
  // 连接后台的ip和端口
  uri: 'http://192.168.3.18:8080/graphql',
  fetch
});

// 创建apollo客户端
const apolloClient = new ApolloClient({
  link: httpLink,
  cache: new InMemoryCache(),
  connectToDevTools: true,
});


export default new VueApollo({
  defaultClient: apolloClient,
  clients: { default: apolloClient },
})
